<%@ page language="java" import="java.util.*,com.fescoservice.model.*" pageEncoding="UTF-8"%>
<%@page import="com.fescoservice.config.PropertiesConfig"%>
<%
	String langfilename = "/resources/message";
	String operType = (String)request.getAttribute("operType");
	if(null==operType) operType ="all";
	Long countl =(Long) request.getAttribute("counts");
	String counts = Long.toString(countl);
	int listSize=PropertiesConfig.getInstance().getInt("ListSize.Operator");
	int pageNumber =(Integer) request.getAttribute("pageNumber");
	int pageCount =(countl.intValue()/listSize)+((0==countl.intValue()%listSize)?0:1);
	List operatorlist =(List<Operator>) request.getAttribute("operatorlist");
%>
<%@include file="../common/LocaleManager.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Fesco Service</title>
		<link rel="stylesheet" href="<%=path%>/js/jquery/themes/redmond/jquery.ui.all.css">
		<script src="<%=path%>/js/jquery/jquery-1.5.1.js"></script>
		<script src="<%=path%>/js/jquery/external/jquery.bgiframe-2.1.2.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.core.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.widget.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.mouse.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.button.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.draggable.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.position.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.resizable.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.ui.dialog.js"></script>
		<script src="<%=path%>/js/jquery/ui/jquery.effects.core.js"></script>
		<script src="<%=path%>/js/jquery/jquery.pager.js"></script>
		<link rel="stylesheet" href="<%=path%>/css/admin.css">	
		<style type="text/css">			
			select#operType{width:200px}			
		</style>
		<script type="text/javascript">
			$(function() {
				function pageClick(pageclickednumber) { 
					document.forms.mainForm.action = '<%=path%>/action/Manage.htm?cmd=operatorlist';
					document.forms.mainForm.page.value=pageclickednumber;
					document.forms.mainForm.submit();		
					//$("#pager").pager({ pagenumber: pageclickednumber, pagecount: 15, buttonClickCallback: PageClick 
				}
				$("#btnAdd").button().click(function() {
					document.forms.mainForm.action = '<%=path%>/action/Manage.htm?cmd=addOperatorInit';
					document.forms.mainForm.submit();		
				});
				$("#btnSearch").button().click(function() {
					document.forms.mainForm.action = '<%=path%>/action/Manage.htm?cmd=operatorlist';
					document.forms.mainForm.submit();		
				});
				$('#operType option').each(function(){ 
					if(this.value=="<%=operType%>") {
						$(this).attr("selected","selected");
					}
				}); 
				$("#pager").pager({ pagenumber: <%=pageNumber%>, pagecount: <%=pageCount%>, buttonClickCallback: pageClick }); 
				
				
			}); 
			


			function goModify(id){
					document.forms.mainForm.action = '<%=path%>/action/Manage.htm?cmd=modifyOperatorInit';
					document.forms.mainForm.operId.value = id;
					document.forms.mainForm.submit();
			}
			var trClass ;
			function trMouseOver(tr){
					trClass=tr.className;
					tr.className='operTR';
				}
			function trMouseOut(tr){
					tr.className=trClass;
				}
		</script>
	</head>
	<body>
		
		<div class="wrapContent">		
			<form name="mainForm" method="post">
				<input type="hidden" name="page" value="" />
				<input type="hidden" name="operId" value="" />
			
			<div class="ui-widget categorylist">
				<div class="search">
					<%=resource.getString("FS_T_SEARCHBYTYPE")%>
					<select name="type" id="operType" class=" ui-corner-all">
						<option value="all"><%=resource.getString("FS_T_ALL")%></option>
						<option value="0"><%=resource.getString("FS_T_OPERTYPE0")%></option>
						<option value="1"><%=resource.getString("FS_T_OPERTYPE1")%></option>
					</select>
					<div id="btnSearch" ><%=resource.getString("FS_T_SEARCH")%></div>
				</div>
				<h1>
					 <%=resource.getString("FS_T_TOTALCOUNT")%> :  <%=counts %> 
				</h1>
				<table class="ui-widget ui-widget-content" style="table-layout:fixed">
				<colgroup>
					<col width="240px" />
					<col width="*" />
					<col width="100px" />
					<col width="100px" />
					<col width="100px" />
				</colgroup>
					<thead>
						<tr class="ui-widget-header ">
							<th>
								<%=resource.getString("FS_T_USERNAME")%>
							</th>
							<th>
								<%=resource.getString("FS_T_ENGLISHNAME")%>
							</th>
							<th>
								<%=resource.getString("FS_T_OPERTYPE")%>
							</th>
							<th>
								<%=resource.getString("FS_T_OPERROLE")%>
							</th>
							<%if("1".equals(operType)){ %>
							<th>
								<%=resource.getString("FS_T_COMPANY")%>
							</th>
							<%}else{ %>						
							<th>
								<%=resource.getString("FS_T_DEPARTMENT")%>
							</th>
							<%}%>
						</tr>
					</thead>
					<tbody>
					<% if(operatorlist.size()>0) { 
							Company company = null;
							Operator operator = null;
							for(int i=0;i<operatorlist.size();i++){
							Object[] o = (Object[]) operatorlist.get(i);
							operator = (Operator)o[0];
							company = (Company) o[1];
					%>
					
						<a href="javascript:void(0);" onclick="goModify('<%=operator.getOperId() %>')">
						<tr class="operTR<%=i%2 %>" onmouseover="trMouseOver(this)" onmouseout="trMouseOut(this)">
							<td nowrap >
								<%=operator.getOperId() %>
							</td>
							<td nowrap >
								<%=operator.getOperName() %>
							</td>
							<td nowrap >
								<%=resource.getString("FS_T_OPERTYPE"+operator.getOperType())%>
							</td>
							<td nowrap >
								<%=resource.getString("FS_T_OPERROLE"+operator.getOperRoleId()) %>
							</td>
							<%if("1".equals(operator.getOperType())){ %>
							<td nowrap >
								<%=("1".equals(operType) && null!=company)?company.getCompName():""%>
							</td>
							<%}else{ %>
							<td nowrap >
								<%=resource.getString("FS_T_DEPARTMENT"+operator.getOperDeptId())%>
							</td>
							<%}%>
						
						</tr></a>
					<%	}
					}else{ %>
						<tr>
							<td nowrap  colspan="5">
								<%=resource.getString("FS_M_NORESULT")%>
							</td>
						</tr>
					<%} %>
					</tbody>
				</table>
				<div class="bottom">
					<div id="pager"></div>
				</div>
				
				<div class="buttonGroupRight">
			   		<div id="btnAdd" ><%=resource.getString("FS_T_ADD")%></div>
					
				</div>	
			</div>
			</form>
		</div>		
		<script type="text/javascript"	>	
		//import scripts below to pages which display in right frame, for ajust the scroll height
		parent.scroll(0,0);
		parent.setFrameHeight(document.body.scrollHeight+200);
		</script>
	</body>
</html>